package com.monkey.luffer.springboot.demo.basis.demo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.monkey.luffer.springboot.demo.basis.example.StreamTest;

import java.util.Arrays;

/**
 * @Author: dengkaibing
 * @Description:
 * @Date: 2020/11/18 16:21
 * @company 甜橙金融
 * @Version: 1.0
 */
public class Test extends StreamTest {
    public static void main(String[] args) {
//        UserDTO uiDTO = new UserDTO();
//        uiDTO.setAge("14");
//        uiDTO.setName("dkb");
//        //DTO BO对象转化，字段名必须一致 类型可不一致
//        UserBo userBo = JSON.parseObject(JSON.toJSONString(uiDTO), new TypeReference<UserBo>() {});
//        System.out.println(userBo);
        testJson();
//        Arrays.asList(null);
//        binaryOperation(1,30);
    }

    public static  boolean binaryOperation(int index ,int agreementCode){
        String str=Integer.toBinaryString(agreementCode);
        System.out.println(str);
        if(index>str.length()) {
            return false;
        }
        char x = str.charAt(str.length() - index);
        System.out.println(x);
        if('1'== x){
            return true;
        }
        return false;
    }

    public static void testJson(){
        UserDTO userDto = new UserDTO();
        userDto.setName("dkb");
//        userDto.setAge("123");
        UserBo userBo = JSON.parseObject(JSON.toJSONString(
            userDto), new TypeReference<UserBo>() {
        });

        System.out.println(userBo.toString());
    }





}
